//Friday, October 30 2009
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}

class BestView
{
public:
	int numberOfBuildings(vector <int> heights)
	{
		vector<int> A = solve(heights);
		reverse(heights.begin(), heights.end());
		vector<int> B = solve(heights);
		reverse(B.begin(), B.end());
		int ret = 0;
		for(int i=0; i<A.size(); i++)
			checkmax(ret, A[i]+B[i]);
		return ret;
	}
	vector<int> solve(vector<int> A)
	{
		vector<int> R(A.size(), 0);
		for(int i=0; i<A.size(); i++)
		{
			long long x1 = 0;
			long long y1 = -1;
			for(int j=i+1; j<A.size(); j++)
			{
				long long x2 = j-i;
				long long y2 = A[j] - A[i];
				if(x1*y2 > x2*y1)
				{
					R[i]++;
					x1 = x2;
					y1 = y2;
				}
			}
		}
		return R;
	}
};
